<template>
  <a-card :bordered="false" v-show='isAchStudentExaminationScoreListShow'>
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :xl="4" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="考试" prop="queryParam.examinationId">
              <j-dict-select-tag v-model="queryParam.examinationId"  placeholder="请选择考试" :dictCode="queryParamSelect.examinationIdSelect"/>
            </a-form-model-item>
          </a-col>

          <a-col :xl="4" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="计分范围(状态)" prop="queryParam.achievementStatus">
              <j-multi-select-tag
                v-model="queryParam.achievementStatus"
                dictCode="achievement_status"
                placeholder="请选择">
              </j-multi-select-tag>
            </a-form-model-item>
          </a-col>

          <a-col :xl="4" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
        <template v-if="toggleSearchStatus">
          <a-row :gutter="24">
            <a-col :xl="3" :lg="7" :md="8" :sm="24">
              <a-form-model-item label="评分标准" prop="queryParam.achiStandPurposeType">
                <!--                <j-dict-select-tag @change='changeAchievementStandardId' v-model="queryParam.achievementStandardId"  :dictCode="queryParamSelect.achievementStandardIdSelect"/>-->
                <j-multi-select-tag
                  v-model="queryParam.achiStandPurposeType"
                  dictCode="achi_stand_purpose_type"
                  placeholder="请选择">
                </j-multi-select-tag>
              </a-form-model-item>
            </a-col>
            <a-col :xl="4" :lg="7" :md="8" :sm="24">
              <a-form-item label = "分数范围" prop="queryParam.achievementScore">
                <label >[</label>
                <a-input-number label = "分数范围:["  v-model ="queryParam.achievementScore_min" style='width: 50px'></a-input-number>
                <label >-</label>
                <a-input-number label = "-"  v-model ="queryParam.achievementScore_max" style='width: 50px' ></a-input-number>
                <label >)</label>
              </a-form-item>
            </a-col>
          </a-row>
        </template>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">

    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
<!--          <a @click="handleEdit(record)">编辑</a>-->

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
<!--              <a-menu-item>-->
<!--                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
<!--                  <a>删除</a>-->
<!--                </a-popconfirm>-->
<!--              </a-menu-item>-->
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getSubjectList, queryTeacherListBySubject } from '@api/commonAPI'

  export default {
    name: 'AchStudentExaminationScoreListComp',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
    },
    props: {
      isAchStudentExaminationScoreListShow: false,
      studentsId: {
        type: String,
        default: ''
      }
    },
    watch:{
      studentsId:{
        immediate: true,
        handler(){
          this.queryParam.studentId = this.studentsId;
          if(this.queryParam.studentId){
            this.loadData();
            console.log("teacherId 发生变化了我刷新了下页面");
          }
        }
      }
    },
    data () {
      return {
        description: 'v_ach_student_examination_score管理页面',
        disableMixinCreated : true, //默认不加载数据
        // 查询条件
        // queryParam: {
        //   achiStandPurposeType: "1",
        // },
        //查询条件联动部分定义
        queryParamSelect: {
          examinationIdSelect: "ach_examination,examination_name,id,del_flag  =0 and iz_open  =1 order by create_time  desc",
          ttclassIdSelect: "cou_class,class_name,id,class_iz_open  =1 and class_iz_delete  = 0 order by  class_order",
          examinationPaperIdSelect: "ach_examination_paper aep,aep.examination_paper_name,aep.id,aep.iz_open =1 and aep.del_flag =0  order by examination_paper_name",
          achievementStandardIdSelect: null,
          // "ach_achievement_standard aas inner join rel_ach_standard_distribution rasd on aas.id = rasd.achievement_standard_id,aas.achievement_standard_name,aas.id,aas.iz_open =1 and aas.del_flag =0 and rasd.paper_standard_effective =1",
          achieveStandardItemIdSelect: null,
          //"ach_achieve_standard_item,stand_item_name,id,iz_open =1 and del_flag =0 order by exa_pap_pro_item_code",
        },
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'年级',
            align:"center",
            dataIndex: 'gradeName'
          },
          {
            title:'班级',
            align:"center",
            dataIndex: 'className'
          },
          {
            title:'班级简称',
            align:"center",
            dataIndex: 'classNickname'
          },
          {
            title:'学号',
            align:"center",
            dataIndex: 'studentNo'
          },
          {
            title:'学生姓名',
            align:"center",
            dataIndex: 'studentName'
          },
          {
            title:'项目',
            align:"center",
            dataIndex: 'exaPapProItemName'
          },
          {
            title:'考试编码',
            align:"center",
            dataIndex: 'examinationCode'
          },
          {
            title:'考试名称',
            align:"center",
            dataIndex: 'examinationName'
          },
          {
            title:'满分',
            align:"center",
            dataIndex: 'examinationFullMarks'
          },
          {
            title:'成绩',
            align:"center",
            dataIndex: 'examinationAchievementScore'
          },
          {
            title:'成绩状态',
            align:"center",
            dataIndex: 'achievementStatusName'
          },
          // {
          //   title:'段位名称',
          //   align:"center",
          //   dataIndex: 'standItemName'
          // },
          {
            title:'段位',
            align:"center",
            dataIndex: 'standItemAliasname'
          },
          {
            title:'段位分差',
            align:"center",
            dataIndex: 'diffScore'
          },
          // {
          //   title:'评分标准',
          //   align:"center",
          //   dataIndex: 'achievementStandardName'
          // },
          {
            title:'标准',
            align:"center",
            dataIndex: 'achiStandPurposeType_dictText'
          },
          {
            title:'班级排名',
            align:"center",
            dataIndex: 'classAchiScoreRank'
          },
          {
            title:'年级排名',
            align:"center",
            dataIndex: 'gradeAchiScoreRank'
          },
          {
            title:'考试日期',
            align:"center",
            dataIndex: 'achievementScoreTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          }
        ],
        url: {
          list: "/achstudent/AchStudentExaminationScoreVo/list",
          exportXlsUrl: "/achstudent/AchStudentExaminationScoreVo/exportXls",
          importExcelUrl: "achstudent/AchStudentExaminationScoreVo/importExcel",

        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {

    },
    mounted() {
      this.clearValue();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      clearValue(){
        this.studentsId='';
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>